package com.example.mys_app;

import android.content.Context;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;


public class tab1 extends Fragment{

    Context context;
    RecyclerView recyclerView;
    View view;
    List list;

    @Override
    public View onCreateView (LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view=inflater.inflate(R.layout.tab1,container,false);
        context=view.getContext();

        recyclerView=view.findViewById(R.id.recyclerview);
        list=new ArrayList();
        for(int i=0;i<10;i++){
            list.add("这是第"+i+"行数据");
        }

        Myadapter myadapter = new Myadapter(context,list);
        recyclerView.setAdapter(myadapter);
        LinearLayoutManager manager=new LinearLayoutManager(context);
        manager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(manager);


        return view;
    }

}